package nix.annotation;

import java.lang.reflect.ParameterizedType;

import org.junit.Test;

public class Demo4 {

	@Test
	public void fun1() {
		new B();// java.lang.String
	}

	@Test
	public void fun2() {
		new C();// java.lang.Integer
	}
}

abstract class A<T> {
	public A() {
		// 反射获得泛型信息
		Class c = (Class) ((ParameterizedType) this.getClass()
				.getGenericSuperclass()).getActualTypeArguments()[0];
		System.out.println(c.getName());
	}
}

class B extends A<String> {

}

class C extends A<Integer> {

}
